package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.entity.PhyExam;
import com.tjetc.entity.Schedule;
import com.tjetc.service.PhyExamService;
import com.tjetc.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("schedule")
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    @RequestMapping("detail/{scheduleId}")
    public JsonResult detail(@PathVariable("scheduleId") Long id) {
        return scheduleService.findById(id);
    }
    @RequestMapping("pagecaregiver")
    public JsonResult pagecaregiver(@RequestParam(value = "name", required = false,defaultValue = "") String name,
                                @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                                @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return scheduleService.findCaregiverPage(name,pageNo,pageSize);
    }
    @RequestMapping("pageemployee")
    public JsonResult pageemployee(@RequestParam(value = "name", required = false,defaultValue = "") String name,
                                   @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                                   @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return scheduleService.findEmployeePage(name,pageNo,pageSize);
    }
    @RequestMapping("delete/{scheduleId}")
    public JsonResult delete(@PathVariable("scheduleId") Long id) {
        return scheduleService.deleteById(id);
    }
    //接收参数格式是json
    @RequestMapping("save")
    public JsonResult save(@RequestBody Schedule schedule){
        return scheduleService.save(schedule);
    }
}
